RE: [SQL] Getting primary key from insert statement
От | Herouth Maoz |
---|---|
Тема | RE: [SQL] Getting primary key from insert statement |
Дата | |
Msg-id | l03130302b382f5c2b12e@[147.233.159.109] обсуждение исходный текст |
Ответ на | RE: [SQL] Getting primary key from insert statement (Michael J Davis <michael.j.davis@tvguide.com>) |
Список | pgsql-sql |
At 19:23 +0300 on 08/06/1999, Michael J Davis wrote: > I accomplish this by trapping the "Before Insert" event in the form used to > add new Status records (the user is NOT entering the StatusID) and doing the > following: > > Form.StatusID = getSeqValue('Status_seq') Thus, you do it in the frontend. Six months later, a programmer writes another form that accesses the same table, and fails to do so, or leaves it to the user. Or he decides that he has a better number generator to use. There are errors. Perhaps his form generates numbers which the sequence has not yet reached. Conflicts ocuur. Boss unhappy. That happens because you failed to centralize the logic of your database. As I said, the "serial" datatype is not a complete fail-safe, because it still allows entering non-sequence values. But at least it's a step in the right direction. Putting the logic in the client side is the wrong thing to do. To finish in a humorous note, I wouldn't use programming practices encouraged by Microsoft products as pillars of truth... Herouth -- Herouth Maoz, Internet developer. Open University of Israel - Telem project http://telem.openu.ac.il/~herutma
В списке pgsql-sql по дате отправления: